/*
* Smart IP Camera
* Copyright (c) BZ <bzchen@allwinnertech.com>
*
* This file is part of SIPC.
*/
#include <stdio.h>
#include <stdarg.h>

#include <ZLog.h>

#define LOG_LEVEL Z_LOG_DEBUG

static inline char LevelTag(int level)
{   
    switch (level)
    {
    case Z_LOG_DEBUG:
        return 'D';
    case Z_LOG_INFO:
        return 'I';
    case Z_LOG_WARNING:
        return 'W';
    case Z_LOG_ERROR:
        return 'E';
    case Z_LOG_FAULT:
        return 'F';
    default:
        return 'X';
    }
    return 'X';
}

void ZLog(int level, char *file, int line, char *fmt, ...)
{
    char buffer[2048] = {0};
    va_list args;

    if (level < LOG_LEVEL)
    {
        /* ignore ... */ 
        return ;
    }
    
    va_start(args, fmt);
    vsnprintf(buffer, 2048, fmt, args);
    va_end(args);

    printf("<%c><%s:%d> %s\n", LevelTag(level), file, line, buffer);
    return ;
}

